package com.longge;

import java.util.HashSet;

public class MaxProduct1 {

    public int maxProduct(String[] words) {

        int max = 0;
        for (int i = 0; i < words.length; i++) {
            char[] chars = words[i].toCharArray();
            HashSet<Character> charSet = new HashSet<>();
            for (char aChar : chars) {
                charSet.add(aChar);
            }
            for (int j = i + 1; j < words.length; j++) {
                char[] charsJ = words[j].toCharArray();
                boolean flag = false;
                for (char c : charsJ) {
                    if (charSet.contains(c)){
                        flag = true;
                        break;
                    }
                }
                if (!flag){
                    max = Math.max(max, chars.length * charsJ.length);
                }
            }
        }
        return max;

    }

}
